package com.fg.cloud.manager.service.system.impl;

import java.util.ArrayList;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.fg.cloud.common.PageUtils;
import com.fg.cloud.manager.entry.BaseEntity;
import com.fg.cloud.manager.entry.system.ProblemInteractiveEntity;
import com.fg.cloud.manager.entry.system.SystemProblemEntity;
import com.fg.cloud.manager.entry.system.vo.SystemProWecharVo;
import com.fg.cloud.manager.entry.system.vo.SystemProblemVo;
import com.fg.cloud.manager.mapper.BaseMapper;
import com.fg.cloud.manager.mapper.system.SystemProblemMapper;
import com.fg.cloud.manager.service.BaseServiceImpl;
import com.fg.cloud.manager.service.system.SystemProblemService;

@Service
public class SystemProblemServiceImpl extends BaseServiceImpl implements SystemProblemService {

	@Autowired
	private SystemProblemMapper systemProblemMapper;
	
	@Override
	protected <T extends BaseEntity> BaseMapper getBaseMapper() {
		return systemProblemMapper;
	}

	/**
	 * 条件查询
	 */
	@Override
	public boolean selectBycondition(SystemProblemEntity systemProblemEntity) {
		
		return systemProblemMapper.selectBycondition(systemProblemEntity)>0 ? true : false;
	}

	/**
	 * 厂商分页查询问题
	 */
	@Override
	public void selectforPage(PageUtils<SystemProblemEntity> pageinfo) {
		long total = systemProblemMapper.filterCount(pageinfo.getCondition());
		pageinfo.setTotal(total);
		if (total > 0) {
			pageinfo.setData(systemProblemMapper.findList(pageinfo));
		} else {
			pageinfo.setData(new ArrayList<SystemProblemEntity>());
		}
	}
	
	/**
	 * 经销商分页查询问题
	 */
	@Override
	public void selectpage(PageUtils<SystemProblemEntity> pageinfo) {
		long total = systemProblemMapper.filterCounts(pageinfo.getCondition());
		pageinfo.setTotal(total);
		if (total > 0) {
			pageinfo.setData(systemProblemMapper.findLists(pageinfo));
		} else {
			pageinfo.setData(new ArrayList<SystemProblemEntity>());
		}
	}
	
	/**
	 * 经销商手机端分页查看
	 */
	@Override
	public void selectWechar(PageUtils<SystemProblemVo> pageinfo) {
		long total = systemProblemMapper.queryCounts(pageinfo.getCondition());
		pageinfo.setTotal(total);
		if (total > 0) {
			pageinfo.setData(systemProblemMapper.queryLists(pageinfo));
		} else {
			pageinfo.setData(new ArrayList<SystemProblemVo>());
		}
	}

	/**
	 * 经销商用户查询
	 */
	@Override
	public SystemProblemEntity find(Long id, Long ageId) {
		
		return systemProblemMapper.findByAge(id, ageId);
	}
	
	/**
	 * 经销商手机端查询详情
	 */
	@Override
	public SystemProWecharVo wfind(Long id, Long ageId) {
		
		return systemProblemMapper.wfind(id, ageId);
	}

	/**
	 * 厂商用户查询
	 */
	@Override
	public SystemProblemEntity findByFac(Long id, Long facId) {
		
		return systemProblemMapper.findByFac(id,facId);
	}


	/**
	 * 厂商回复经销商
	 */
	@Override
	@Transactional
	public boolean reply(ProblemInteractiveEntity interactive) {
		
		return systemProblemMapper.reply(interactive) > 0 ? true : false ;
	}

	

	

	

	

}
